//
//  LoginAndRegistManager.m
//  YIChuSeller
//
//  Created by 田小椿 on 2018/12/20.
//  Copyright © 2018年 xiangshengjun. All rights reserved.
//

#import "LoginAndResetManager.h"

@implementation LoginAndResetManager

+ (void)loginWithPhone:(NSString *)phone password:(NSString *)password success:(CompleteHandle)success fail:(CompleteHandle)fail{
    NSDictionary * jsonStr = [NSDictionary dictionary];
    jsonStr = @{@"api":@"100",
                @"parameters":@{
                        @"phone":phone,
                        @"password":password,
                        @"email":@""
                        }
                };
    [SVProgressHUD showWithStatus:@"登录中" maskType:SVProgressHUDMaskTypeClear];
    [HttpHelper Post:@"ycs/User/User.do" parameters:jsonStr success:^(id responseObject) {
        if ([responseObject[@"cod"] isEqualToString:@"001"]) {
//            [MBProgressHUD showSuccess:@"登录成功"];
            [SVProgressHUD showSuccessWithStatus:@"登录成功"];
            success(responseObject);
        }else{
//            [MBProgressHUD showError:responseObject[@"describa"]];
            [SVProgressHUD showErrorWithStatus:responseObject[@"describa"]];
        }
    } failure:^(NSError *error) {
        [SVProgressHUD showErrorWithStatus:@"请求数据失败"];
        fail(error);
    }];
}


+ (void)changePasswordWithPhone:(NSString *)phone repassword:(NSString *)repassword success:(CompleteHandle)success fail:(CompleteHandle)fail{
       [SVProgressHUD showWithStatus:@"修改中" maskType:SVProgressHUDMaskTypeClear];
    NSDictionary * jsonStr = [NSDictionary dictionary];
    jsonStr = @{@"api":@"YCS_USER_UPDATEPASSWORD",
                @"parameters":@{
                        @"phone":phone,
                        @"repassword":repassword
                        }
                };
    [HttpHelper Post:@"ycs/User/User.do" parameters:jsonStr success:^(id responseObject) {
        if (responseObject) {
             success(responseObject);
        }
    } failure:^(NSError *error) {
        [SVProgressHUD showErrorWithStatus:@"请求数据失败"];
        fail(error);
    }];
}
+ (void)changePhoneNumberWithPhone:(NSString *)phone UserId:(NSString *)userId success:(CompleteHandle)success fail:(CompleteHandle)fail
{
    [SVProgressHUD showWithStatus:@"更改中" maskType:SVProgressHUDMaskTypeClear];
    NSDictionary * jsonStr = [NSDictionary dictionary];
    jsonStr = @{@"api":@"UPDATE_USER_USERPHONE",
                @"parameters":@{
                        @"phone":phone,
                        @"userId":userId
                        }
                };
    [HttpHelper Post:@"ycs/User/User.do" parameters:jsonStr success:^(id responseObject) {
        if (responseObject) {
            success(responseObject);
        }
    } failure:^(NSError *error) {
        [SVProgressHUD showErrorWithStatus:@"请求数据失败"];
        fail(error);
    }];
}



@end
